#include <QPainter>

#include "soundIcon.h"

soundIcon::soundIcon(QWidget *parent) : QWidget(parent)
{
    this->setFixedSize(25, 50);
    //isMouseIn = 0;
    isMute = 0;

    this->setCursor(Qt::ArrowCursor);

}


void soundIcon::paintEvent(QPaintEvent *event)
{
    (void) event;
    QPainter painter(this);
    painter.fillRect(this->rect(), QColor(0, 0, 0, 0));
    if(isMute == 0)
        painter.drawImage(QPointF(0, 12.5), QImage(":/icon/img/sound.png"));
    else
        painter.drawImage(QPointF(0, 12.5), QImage(":/icon/img/soundMute.png"));

}

void soundIcon::mousePressEvent(QMouseEvent *event)
{
    if(isMute == 0)
    {
        isMute = 1;
    }
    else
    {
        isMute = 0;
    }
    emit muteChanged(isMute);
    update();

}

void soundIcon::mouseMoveEvent(QMouseEvent *event)
{
    //isMouseIn = 1;
    this->setCursor(Qt::PointingHandCursor);
}

void soundIcon::enterEvent(QEvent *event)
{
    //isMouseIn = 1;
    this->setCursor(Qt::PointingHandCursor);
}

void soundIcon::leaveEvent(QEvent *event)
{
    //isMouseIn = 0;
    this->setCursor(Qt::ArrowCursor);
}
